<div class="content-wrapper">
    <section class="content-header">
        <h1>设置列表</h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">公共配置</li>
            <li class="active">设置列表</li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-header with-border">
            </div>
            <div class="box-body table-responsive">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <th style="width: 80px">ID</th>
                        <th>名称</th>
                        <th>状态</th>
                        <th style="width: 100px">操作</th>
                    </tr>
                    <if condition="count($resList) eq 0"><tr><td class="text-center" colspan="4">暂无数据...</td></tr></if>
                    <foreach name="resList" item="item">
                        <tr>
                            <td>{$item.id}</td>
                            <td>{$item.title}</td>
                            <td>
                                <if condition="$item.status eq 1">
                                    <span class="label label-success">开启</span>
                                    <else />
                                    <span class="label label-warning">关闭</span>
                                </if>
                            </td>
                            <td>
                                <button class="btn btn-primary btn-xs" type="button" onclick="window.location.href='/commonSet/editCommonSet?id={$item.id}'">编辑</button>&nbsp;
                                <if condition="$item.status eq 2">
                                        <button class="btn btn-success btn-xs" type="button" onclick="return change_status(this,1)" data-id="{$item.id}">开启</button>&nbsp;
                                    <else />
                                        <button class="btn btn-danger btn-xs" type="button" onclick="return change_status(this,2)" data-id="{$item.id}">关闭</button>&nbsp;
                                </if>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
        </div>
    </section>
</div>
<script type="application/javascript">
    function change_status(obj,status) {
        var id = $(obj).attr('data-id');
        $.post('/admin/CommonSet/ajaxSaveCommonSet',{
            id: id,
            status: status
        },function (data) {
            if(data.Code == 999) {
                ArtDialogHlp.showInfo('提示', '操作成功', function(){
                    window.location.reload(true)
                });
            } else {
                ArtDialogHlp.showInfo('提示', data.Msg);
            }
        },"JSON");
    }
</script>